home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / dynamenu / dynamenu.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  4.1 KB  |  158 lines

  1. // dynamenu.cpp
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1999 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. //
  13. // Purpose: implementation of the CDynaMenuApp class
  14. //
  15. // Functions:
  16. //      Most of this file was generated by AppWizard.  The functions
  17. //      which contain code specific to this sample are:
  18. //
  19. //      CDynaMenuApp::InitInstance()         -- per-instance initialization
  20.  
  21. #include "stdafx.h"
  22. #include "dynamenu.h"
  23.  
  24. #include "mainfrm.h"
  25. #include "dmdoc.h"
  26. #include "dmview.h"
  27.  
  28. #ifdef _DEBUG
  29. #undef THIS_FILE
  30. static char BASED_CODE THIS_FILE[] = __FILE__;
  31. #endif
  32.  
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CDynaMenuApp
  35.  
  36. BEGIN_MESSAGE_MAP(CDynaMenuApp, CWinApp)
  37.     //{{AFX_MSG_MAP(CDynaMenuApp)
  38.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  39.     //}}AFX_MSG_MAP
  40.     // Standard file based document commands
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // The one and only CDynaMenuApp object
  45.  
  46. CDynaMenuApp theApp;
  47.  
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CDynaMenuApp initialization
  50.  
  51. //***********************************************************************
  52. // Function: CDynaMenuApp::InitInstance()
  53. //
  54. // Purpose:
  55. //      InitInstance is called by the framework to perform per-instance
  56. //      initialization of the application.
  57. //
  58. //      This function is the code generated by AppWizard with one
  59. //      exception - we use our own class for the frame window attached
  60. //      to a document template, instead of using CMDIChildWnd.
  61. //
  62. // Parameters:
  63. //      none
  64. //
  65. // Returns:
  66. //      nonzero if successful, otherwise 0
  67. //
  68. // Comments:
  69. //      see the CWinApp::InitInstance() documentation for further info.
  70. //
  71. //***********************************************************************
  72. BOOL CDynaMenuApp::InitInstance()
  73. {
  74.     // Standard initialization
  75.     // If you are not using these features and wish to reduce the size
  76.     //  of your final executable, you should remove from the following
  77.     //  the specific initialization routines you do not need.
  78.  
  79.     // Register the application's document templates.  Document templates
  80.     //  serve as the connection between documents, frame windows and views.
  81.  
  82.     CSingleDocTemplate* pDocTemplate;
  83.     pDocTemplate = new CSingleDocTemplate(
  84.         IDR_MAINFRAME,
  85.         RUNTIME_CLASS(CDynaMenuDoc),
  86.         RUNTIME_CLASS(CMainFrame),
  87.         RUNTIME_CLASS(CDynaMenuView));
  88.     AddDocTemplate(pDocTemplate);
  89.  
  90.     OnFileNew();
  91.     ((CMainFrame*)m_pMainWnd)->RefreshColorMenu();
  92.  
  93.     return TRUE;
  94. }
  95.  
  96. /////////////////////////////////////////////////////////////////////////////
  97. // CAboutDlg dialog used for App About
  98.  
  99. class CAboutDlg : public CDialog
  100. {
  101. public:
  102.     CAboutDlg();
  103.  
  104. // Dialog Data
  105.     //{{AFX_DATA(CAboutDlg)
  106.     enum { IDD = IDD_ABOUTBOX };
  107.     //}}AFX_DATA
  108.  
  109. // Implementation
  110. protected:
  111.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  112. protected:
  113.     //{{AFX_MSG(CAboutDlg)
  114.     virtual BOOL OnInitDialog();
  115.     //}}AFX_MSG
  116.     DECLARE_MESSAGE_MAP()
  117. };
  118.  
  119. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  120. {
  121.     //{{AFX_DATA_INIT(CAboutDlg)
  122.     //}}AFX_DATA_INIT
  123. }
  124.  
  125. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  126. {
  127.     CDialog::DoDataExchange(pDX);
  128.     //{{AFX_DATA_MAP(CAboutDlg)
  129.     //}}AFX_DATA_MAP
  130. }
  131.  
  132. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  133.     //{{AFX_MSG_MAP(CAboutDlg)
  134.         // No message handlers
  135.     //}}AFX_MSG_MAP
  136. END_MESSAGE_MAP()
  137.  
  138. /////////////////////////////////////////////////////////////////////////////
  139. // CAboutDlg message handlers
  140.  
  141. BOOL CAboutDlg::OnInitDialog() 
  142. {
  143.     CDialog::OnInitDialog();
  144.     CenterWindow();    
  145.     return TRUE;  
  146. }
  147.  
  148. // App command to run the dialog
  149. void CDynaMenuApp::OnAppAbout()
  150. {
  151.     CAboutDlg aboutDlg;
  152.     aboutDlg.DoModal();
  153. }
  154.  
  155. /////////////////////////////////////////////////////////////////////////////
  156. // CDynaMenuApp commands
  157.  
  158.